/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kurvykurvy.page;

import com.kurvykurvy.image.LoadedImage;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 *
 * @author HY
 */
public class ImageFrameFactory
{
    public static ImageFrame createImageFrame( ImageFrameTemplate template, LoadedImage img )
    {
        ImageFrame result = new ImageFrameImpl( template, img );
        result.setSize( template.getSize() );
        return result;
    }

    public static ImageFrame createImageFrame( ImageFrameTemplate template, BufferedImage img )
    {
        Dimension size = template.getSize();
        BufferedImage scaledImage = new BufferedImage( size.width, size.height, BufferedImage.TYPE_INT_RGB );
        Graphics2D g2 = (Graphics2D) scaledImage.getGraphics();
        g2.drawImage( img, 0, 0, size.width, size.height, null );
        g2.dispose();

        ImageFrame result = new ImageFrameImpl( template, scaledImage );
        return result;
    }
}
